<?php
/*
 * author: fabricio s costa
 * version: 1.0
 * site: http://fabriciojf.com
 */
require_once('com/fabriciojf/action/Action.class.php');
require_once('com/fabriciojf/model/Ticket.class.php');
require_once('com/fabriciojf/security/Permission.class.php');
require_once('com/fabriciojf/persistence/DaoGenerico.class.php');

class TicketUpdateAction implements Action {
    public function execute() {
        $roles[] = 'admin';
        Permission::requireInRole($roles);

        $ticket = new Ticket();
        $ticket->setId($_POST['ticketId']);
        $ticket->setTelefone($_POST['telefone']);
        $ticket->setAssunto($_POST['assunto']);
        $ticket->setMensagem($_POST['mensagem']);
        $ticket->setDataHora(date('Y-m-d H:i:s'));
        $ticket->setStatus(Dao::findForId(1, 'StatusTicket'));

        Dao::update($ticket, 'Ticket');
        FrontController::sendRedirect('TicketListar');

    }
}
?>
